package try01;

public class RotateImage {
	public void rotate(int[][] matrix) {
        int n = matrix.length;
        int r = n/2 + n%2;
        int c = n/2;
        
        for(int i = 0 ; i < r ; i ++) {
            for(int j = 0 ; j < c ; j++) {
                rotate1(matrix, i, j);
            }
        }
    }
    
    public void rotate1(int[][]m, int r, int c) {
        int n = m.length;
        int t1, t2, t3, t4;
        t1 = m[r][c];
        t2 = m[c][n-r];
        t3 = m[n-r][n-c];
        t4 = m[n-c][r];
        
        m[c][n-r] = t1;
        m[n-r][n-c] = t2;
        m[n-c][r] = t3;
        m[r][c] = t4;
    }
}